AC_INIT([eclib],[20120115])
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([m4])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
LT_INIT

dnl Checks for header files.
AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST


dnl set ARITH (should be ./configure-able)
dnl ifeq ($(ARITH),NTL_INTS)
dnl LIBBASE = libjcntlint
dnl NTLCFLAGS = -DNTL_INTS -I$(NTLINCDIR)
dnl NTLLFLAGS = -L$(NTLLIBDIR) -lntl -lgmp -lpari
dnl OBJ_SUF = _ntl
dnl else
dnl LIBBASE = libjcntl
dnl NTLCFLAGS = -DNTL_ALL -I$(NTLINCDIR)
dnl NTLLFLAGS = -L$(NTLLIBDIR) -lntl -lgmp -lpari
dnl OBJ_SUF = _n
dnl endif
NTL_ARITH=-DNTL_ALL 


dnl Find PARI
AC_ARG_WITH(pari,
  [AS_HELP_STRING([--with-pari=<path>],  
                  [prefix of PARI installation. e.g. /usr/local or /usr])],
  [PARI_PREFIX="$with_pari"],
  [AC_CHECK_LIB([pari], [pari_kernel_init], ,
    AC_MSG_ERROR([Pari library not found.
    Maybe you want to call configure with the --with-pari=<path> option?
    This tells configure where to find the PARI library and headers.
    e.g. --with-pari=/usr/local or --with-pari=/usr]))]
)
if test "x$PARI_PREFIX" != x ; then
  PARI_LIBS=" -L${PARI_PREFIX}/lib"
  PARI_CFLAGS=" -I${PARI_PREFIX}/include"
else
  PARI_LIBS=""
  PARI_CFLAGS=""
fi
PARI_LIBS="${PARI_LIBS} -lpari"
AC_SUBST(PARI_LIBS)
AC_SUBST(PARI_CFLAGS)



dnl Find the NTL Library
AC_ARG_WITH(ntl,
  [AS_HELP_STRING([--with-ntl=<path>],  
                  [prefix of NTL installation. e.g. /usr/local or /usr])],
  [NTL_PREFIX="$with_ntl"],
  [AC_CHECK_LIB([ntl], [_ntl_gmul], ,
    AC_MSG_ERROR([NTL Library not found.
    Maybe you want to call configure with the --with-ntl=<path> option?
    This tells configure where to find the NTL library and headers.
    e.g. --with-ntl=/usr/local or --with-ntl=/usr]))]
)
if test "x$NTL_PREFIX" != x ; then
  NTL_LIBS=" -L${NTL_PREFIX}/lib"
  NTL_CFLAGS="${NTL_ARITH} -I${NTL_PREFIX}/include"
else
  NTL_LIBS=""
  NTL_CFLAGS="${NTL_ARITH}"
fi
NTL_LIBS="${NTL_LIBS} -lgmp -lntl"
AC_SUBST(NTL_LIBS)
AC_SUBST(NTL_CFLAGS)


dnl ===== End checks for libraries ================

dnl Finishing it up
AC_CONFIG_FILES([
  procs/Makefile 
  Makefile
])
AC_OUTPUT

#  qcurves/Makefile 
#  qrank/Makefile 
#  g0n/Makefile 
